#include "ti_msp_dl_config.h"
//#include "stdio.h"
#include "flexible_button.h"
#include "Emm_V5.h"
#include "upper_community.h"

extern RxContext community_rx_buffer;
extern ring_buffer_t rx_fifo;

void K230_Com_INST_IRQHandler(void)
{
    switch( DL_UART_getPendingInterrupt(K230_Com_INST) )
    {
        case DL_UART_IIDX_RX:
		{
			volatile uint8_t rx_byte = DL_UART_receiveData(K230_Com_INST);
			
			//put the received data to the ring buffer
			if(!com_ring_buffer_is_full(&rx_fifo))
			{
				com_ring_buffer_put(&rx_fifo,rx_byte);
			}
			

			/* put the parse function to the main while function */
			
            //com_process_rx_byte(&community_rx_buffer,rx_byte);
			//com_frame_parse(community_rx_buffer.frame);
            break;
		}
        default:
            break;		
    }
}

void ZDT_Com_INST_IRQHandler(void)
{
    switch( DL_UART_getPendingInterrupt(ZDT_Com_INST) )
    {
        case DL_UART_IIDX_RX:
		{
			//uart_data = DL_UART_receiveData(UART_0_INST);
            //printf("Hello");
            break;		
		}
        default:
            break;		
    }
}



void SysTick_Handler(void)
{
	flex_button_scan();
}
